<?php
/**
 *
 * User: Jessica@aweb.wang
 * Date: 2023/3/10 14:50
 * Email: <1194323013@qq.com>
 *                            _ooOoo_
 *                           o8888888o
 *                           88" . "88
 *                           (| -_- |)
 *                           O\  =  /O
 *                        ____/`---'\____
 *                      .'  \\|     |//  `.
 *                     /  \\|||  :  |||//  \
 *                    /  _||||| -:- |||||-  \
 *                    |   | \\\  -  /// |   |
 *                    | \_|  ''\---/''  |   |
 *                    \  .-\__  `-`  ___/-. /
 *                  ___`. .'  /--.--\  `. . __
 *               ."" '<  `.___\_<|>_/___.'  >'"".
 *              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
 *              \  \ `-.   \_ __\ /__ _/   .-` /  /
 *         ======`-.____`-.___\_____/___.-`____.-'======
 *                            `=---='
 *        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 *                      Buddha Bless, No Bug !
 **/

namespace app\index\controller;
use app\common\exception\BusinessException;
use app\common\exception\BusinessExceptionEnum;
use app\common\utils\ExcelUtils;
use app\common\utils\MailUtils;
use app\common\utils\ResponseUtils;
use app\common\utils\SmsUtils;
use think\cache\driver\Redis;
use think\facade\Config;
use think\facade\Queue;
use think\facade\Request;

class Index
{
    public function sendMsg(){
        $code=SmsUtils::send('18395614415');

    }
    public function sendMail(){
        MailUtils::send('测试邮件','shdjkfhjskdhfjksdjhkfsd',['1194323013@qq.com']);
        return ResponseUtils::retSuccess();
    }
    public function makeJob(){
        $orderSn=Request::get('orderSn');
        $customerClassName='app\job\Task';
        $queueName='task';
        $orderData=['order_sn'=>$orderSn];
        $isPushed=Queue::later(10,$customerClassName,$orderData,$queueName);
        if($isPushed!==false){
            echo '队列添加成功';
        }else{
            echo '插入队列失败了';
        }
    }
    public function redisTest(){
        $redis=new Redis(Config::get('cache.stores.redis'));
        $redis->set('passwu','test');
        $pasa=$redis->get('passwu');
        dd($pasa);
    }
    public function swTest(){

        try{
            $a=1;
            throw new BusinessException(BusinessExceptionEnum::FILE_EMPTY);
            $b=1;
        }catch(\Exception $e){
//            $e->
            throw $e;

            //print_r($e->getCode());
            //$e->getMessage();

        }
    }
    public function index($id){
        echo $id;
        print_r(Config::get('app.mchid'));
        exit;
    }
    public function makeexcel(){
        $data=[['年龄','性别','姓名'],[12,'女','书蓉'],[11,'男','自征']];
        ExcelUtils::makeExcel($data,'人员','人员','人员列表','人员','OA');
    }

}